package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.EmployeeBasicInfo;
import com.ruoyi.system.service.IEmployeeBasicInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工基本信息Controller
 * 
 * @author ruoyi
 * @date 2025-05-22
 */
@Api(tags = "员工基本信息")
@RestController
@RequestMapping("/system/info")
public class EmployeeBasicInfoController extends BaseController
{
    @Autowired
    private IEmployeeBasicInfoService employeeBasicInfoService;

    /**
     * 查询员工基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(EmployeeBasicInfo employeeBasicInfo)
    {
        startPage();
        List<EmployeeBasicInfo> list = employeeBasicInfoService.selectEmployeeBasicInfoList(employeeBasicInfo);
        return getDataTable(list);
    }

    /**
     * 导出员工基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "员工基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmployeeBasicInfo employeeBasicInfo)
    {
        List<EmployeeBasicInfo> list = employeeBasicInfoService.selectEmployeeBasicInfoList(employeeBasicInfo);
        ExcelUtil<EmployeeBasicInfo> util = new ExcelUtil<EmployeeBasicInfo>(EmployeeBasicInfo.class);
        util.exportExcel(response, list, "员工基本信息数据");
    }

    /**
     * 获取员工基本信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{employeeId}")
    public AjaxResult getInfo(@PathVariable("employeeId") String employeeId)
    {
        return success(employeeBasicInfoService.selectEmployeeBasicInfoByEmployeeId(employeeId));
    }

    /**
     * 新增员工基本信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "员工基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmployeeBasicInfo employeeBasicInfo)
    {
        return toAjax(employeeBasicInfoService.insertEmployeeBasicInfo(employeeBasicInfo));
    }

    /**
     * 修改员工基本信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "员工基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmployeeBasicInfo employeeBasicInfo)
    {
        return toAjax(employeeBasicInfoService.updateEmployeeBasicInfo(employeeBasicInfo));
    }

    /**
     * 删除员工基本信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "员工基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{employeeIds}")
    public AjaxResult remove(@PathVariable String[] employeeIds)
    {
        return toAjax(employeeBasicInfoService.deleteEmployeeBasicInfoByEmployeeIds(employeeIds));
    }
}
